package com.niiwoo.civet.user.enums;

import com.niiwoo.tripod.tiancheng.component.TianChengRefundEventService;
import com.niiwoo.tripod.tiancheng.component.TianchengDataFlowService;
import com.niiwoo.tripod.tiancheng.enums.FunctionCodeEnum;
import com.niiwoo.tripod.tiancheng.request.df.*;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: wuke
 * @Description: 数据迁移重试类型枚举
 * @Date: Created in 15:41 2018/1/10
 */
@Getter
@AllArgsConstructor
public enum DataBackFlowRetryTypeEnum {
    START_AFTER_LOGIN_DATAFLOW(FunctionCodeEnum.START_AFTER_LOGIN_DATAFLOW, TianchengDataFlowService.class,"startAfterLogin",StartAfterLoginRequest.class),
    SPEED_LOAN_CREDIT_DATA_FLOW(FunctionCodeEnum.SPEED_LOAN_CREDIT_DATA_FLOW,TianchengDataFlowService.class,"speedLoanCredit",SpeedLoanCreditRequest.class),
    ABORTIVE_PROJECT(FunctionCodeEnum.ABORTIVE_PROJECT,TianchengDataFlowService.class,"abortiveProject",AbortiveProjectDataFlowRequest.class),
    PROJECT_STATUS_CHANGE(FunctionCodeEnum.PROJECT_STATUS_CHANGE,TianchengDataFlowService.class,"projectStatusChange",ProjectStatusChangeDataFlowRequest.class),
    MESSAGE_INFO(FunctionCodeEnum.MESSAGE_INFO,TianchengDataFlowService.class,"messageInfo",MessageInfoRequest.class),
    TALK_RECORD(FunctionCodeEnum.TALK_RECORD,TianchengDataFlowService.class,"talkRecord",TalkRecordRequest.class),
    APPLICATION_LIST(FunctionCodeEnum.APPLICATION_LIST,TianchengDataFlowService.class,"applicationList",ApplicationListRequest.class),
    PERSONAL_INFO_FLOW(FunctionCodeEnum.PERSONAL_INFO_FLOW,TianchengDataFlowService.class,"personalInfo",PersonalInfoRequest.class),
    PROFESSION_INFO_FLOW(FunctionCodeEnum.PROFESSION_INFO_FLOW,TianchengDataFlowService.class,"professionInfo",ProfessionInfoRequest.class),
    IDENTITY_AUTH_DATAFLOW(FunctionCodeEnum.IDENTITY_AUTH_DATAFLOW,TianchengDataFlowService.class,"identityAuth",IdentityInfoRequest.class),
    BANK_INFO_DATAFLOW(FunctionCodeEnum.BANK_INFO_DATAFLOW,TianchengDataFlowService.class,"bankInfo",BankInfoRequest.class),
    LOAN_INFO_FLOW(FunctionCodeEnum.LOAN_INFO_FLOW,TianchengDataFlowService.class,"loanInfo",LoanInfoRequest.class),
    REGISTER_SUCCESS(FunctionCodeEnum.REGISTER_SUCCESS,TianchengDataFlowService.class,"registerSuccess",RegisterSuccessRequest.class),
    LOGIN_SUCCESS(FunctionCodeEnum.LOGIN_SUCCESS,TianchengDataFlowService.class,"loginSuccess",LoginSuccessRequest.class),
    SIGN_SUCCESS(FunctionCodeEnum.SIGN_SUCCESS,TianchengDataFlowService.class,"signSuccess",UserSignSuccessRequest.class),
    INVEST_SUCCESS(FunctionCodeEnum.INVEST_SUCCESS,TianchengDataFlowService.class,"investSuccess",InvestSuccessRequest.class),
    REPAYMENT_PLAN(FunctionCodeEnum.REPAYMENT_PLAN,TianchengDataFlowService.class,"repaymentPlan",RepaymentPlanRequest.class),
    INVEST_REFUND(FunctionCodeEnum.INVEST_REFUND,TianchengDataFlowService.class,"investRefund",InvestRefundRequest.class),
    BLACKLIST_REFUND(FunctionCodeEnum.BLACKLIST_REFUND,TianchengDataFlowService.class,"blackListRefund",BlackListRefundRequest.class),

    MOBILE_NO_FLOW(FunctionCodeEnum.MOBILE_NO_FLOW,TianchengDataFlowService.class,"mobileNoFlow",ChangeMobileNoRequest.class),

    PROJECT_REFUND(FunctionCodeEnum.PROJECT_REFUND, TianChengRefundEventService.class,"refundSucceed",ProjectRefundEventRequest.class),
    PROJECT_OVERDUE(FunctionCodeEnum.PROJECT_OVERDUE,TianChengRefundEventService.class,"projectOverdue",ProjectOverdueEventRequest.class);



    private FunctionCodeEnum functionCodeEnum;
    private Class backFlowServiceClass;
    private String backFlowMethodName;
    private Class backFlowRequestClass;

    public static DataBackFlowRetryTypeEnum getByFunctionCode(String functionCode) {
        for (DataBackFlowRetryTypeEnum dataBackFlowRetryTypeEnum : values()) {
            if (dataBackFlowRetryTypeEnum.getFunctionCodeEnum().getBodyFunctionCode().equals(functionCode)) {
                return dataBackFlowRetryTypeEnum;
            }
        }
        return null;
    }
}
